﻿using System.ComponentModel.DataAnnotations;
using System.Reflection;

namespace Sunxsh.Es.Core.Annotations;

/// <summary>
/// 系统分组信息，主要是给swagger生成文档分组使用
/// </summary>
public class HuaskyAPIGroup
{
    [Display(Name = "应用")]
    public const string App = nameof(App);

    public static Dictionary<string, string> DisplayDic()
    {
        var fields = typeof(HuaskyAPIGroup).GetFields();
        var dic = new Dictionary<string, string>();

        foreach (var field in fields)
        {
            var display = field.GetCustomAttribute<DisplayAttribute>()?.Name;

            display ??= field.Name;
            dic[field.Name] = display;
        }

        return dic;
    }
}
